package com.thd.springboottest.ai.controller;

import org.springframework.ai.openai.OpenAiChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/ai")
public class AiController {
    @Autowired
    private OpenAiChatClient openAiChatClient;

    @GetMapping("/test")
    @ResponseBody
    public String test() {
        System.out.println("SUCCESS");
        return "SUCCESS";
    }

    @GetMapping("/chat")
    @ResponseBody
    public String chat(@RequestParam String message) {
        String result = openAiChatClient.call(message);
        return result;
    }
}
